import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { Global } from "../../../../com/gengine/global/Global";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { TowerInfoHideButton } from "../copy/magicTower/TowerInfoHideButton";
import { ImagesConst } from "../../resource/ImagesConst";
import { GBox } from "../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../com/mui/containers/globalVariable/GBoxDirection";
import { SecTimerView } from "../common/SecTimerView";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { CutCountDetails } from "./CutCountDetails";
import { SoundManager } from "../../../common/sound/SoundManager";
import { SoundTypeConst } from "../../../common/sound/SoundTypeConst";
import { DataEvent } from "../../events/DataEvent";
import { CopyScoreConfig } from "../../resource/CopyScoreConfig";
import { SceneRange } from "../../scene/map/SceneRange";
import { TweenMax } from "../../../../com/greensock/TweenMax";
import { Quint } from "../../../../com/greensock/easing/Quint";
import { TaskCache } from "../../cache/TaskCache";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class CoinCopyInfoView
    
    export  class CoinCopyInfoView extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.x = Global.stage.stageWidth - CoinCopyInfoView.__width;
            this.y = CoinCopyInfoView.__y;
            this.init();
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            Dispatcher.addEventListener(EventName.TrackClick, this.onTaskTrackClick);
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            if (this._tfLeftTime) 
            {
                this._tfLeftTime.dispose();
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            var loc2=null;
            this.mouseEnabled = false;
            loc1 = new GTextFormat(FontUtil.songtiName, 12, 6350622);
            loc1.leading = 7;
            loc2 = new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc2.leading = 5;
            this._textFormatTime1 = new GTextFormat(FontUtil.songtiName, 14, 65286);
            this._textFormatTime2 = new GTextFormat(FontUtil.songtiName, 14, 16580352);
            this._textFormatTime3 = new GTextFormat(FontUtil.songtiName, 14, 14884639);
            this._textFormatTime1.bold = true;
            this._textFormatTime2.bold = true;
            this._textFormatTime3.bold = true;
            this._bodySp = new Object /* flash.display.Sprite */();
            this.addChild(this._bodySp);
            this._topSp = new Object /* flash.display.Sprite */();
            this._bodySp.addChild(this._topSp);
            this._moveBtn = ObjCreate.createGButton("", 0, 3, 24, 22, this._topSp, "MoveBtn");
            this._moveBtn.toolTipData = HTMLUtil.addColor(Language.getString(42007), "#FFFFFF");
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMoveBtnHandler);
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onMoveBtnHandler);
            this._btnDetails = ObjCreate.createGButton("", 22, 0, 188, 28, this._topSp, "TabButtonBig2");
            this._bmpDetails = new Object /* flash.display.Bitmap */();
            this._bmpDetails.y = 3;
            this._bmpDetails.x = 53;
            this._btnDetails.addChild(this._bmpDetails);
            LoaderManager.instance.load("coinCopyDetails.png", this.onLoadComplete);
            this._zoomBtn = new TowerInfoHideButton(ImagesConst.CoinCopyInfoButtonBg);
            this._zoomBtn.x = 222;
            this._zoomBtn.y = 13;
            this.addChild(this._zoomBtn);
            this._zoomBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onZoomBtnClick);
            this._spContent = new Object /* flash.display.Sprite */();
            this._spContent.mouseEnabled = false;
            this._spContent.y = 22;
            this._bodySp.addChild(this._spContent);
            var loc3=new Object /* flash.display.Bitmap */(new Object /* flash.display.BitmapData */(231, 245, true, 4278190080));
            loc3.alpha = 0.5;
            loc3.y = 1;
            this._spContent.addChild(loc3);
            this._box = new GBox();
            this._box.verticalGap = 4;
            this._box.direction = GBoxDirection.VERTICAL;
            this._spContent.addChild(this._box);
            var loc4;
            (loc4 = this.getSp()).mouseChildren = true;
            var loc5;
            (loc5 = ObjCreate.createTextField("", 10, 0, 210, 40, loc4, loc1)).multiline = true;
            loc5.wordWrap = true;
            loc5.htmlText = Language.getString(42008);
            loc5.addEventListener(flash.events.TextEvent.LINK, this.onTextTarget);
            var loc6=this.getSp();
            this._tfLeftTime = new SecTimerView();
            this._tfLeftTime.setParse(Language.getString(42009));
            this._tfLeftTime.defaultTextFormat = this._textFormatTime1;
            this._tfLeftTime.setLeftTime(3600);
            this._tfLeftTime.filters = [FilterConst.glowFilter];
            ObjCreate.setObjAttri(this._tfLeftTime, 10, 0, 200, 20, loc6);
            this._tfLeftTime.addEventListener(EventName.SecViewTimeChange, this.onSecViewTimeChange);
            var loc7=this.getSp();
            ObjCreate.createTextField(Language.getString(42010), 50, 0, 70, 20, loc7, GlobalStyle.textFormat6);
            this._tfGetCoinNum = ObjCreate.createTextField("0", 120, 0, 60, 20, loc7, GlobalStyle.textFormat6);
            ObjCreate.createBitmap("Tongqian", 180, 0, loc7);
            this._tfGetBindCoinNum = ObjCreate.createTextField("0", 120, 20, 60, 20, loc7, GlobalStyle.textFormat6);
            ObjCreate.createBitmap("Tongqian_bind", 180, 20, loc7);
            var loc8=this.getSp();
            ObjCreate.createTextField(Language.getString(42011), 50, 0, 70, 20, loc8, GlobalStyle.textFormat6);
            this._tfKillBossNum = ObjCreate.createTextField("0", 120, 0, 80, 20, loc8, GlobalStyle.textFormat6);
            var loc9=this.getSp();
            ObjCreate.createTextField(Language.getString(42012), 50, 0, 70, 20, loc9, GlobalStyle.textFormat6);
            this._tfKillMonsterNum = ObjCreate.createTextField("0", 120, 0, 80, 20, loc9, GlobalStyle.textFormat6);
            var loc10=this.getSp();
            var loc11;
            (loc11 = ObjCreate.createTextField(Language.getString(42013), 5, 0, 210, 35, loc10, loc2)).multiline = true;
            loc11.wordWrap = true;
            var loc12=ResouceConst.getScaleBitmap("SplitLine");
            ObjCreate.setObjAttri(loc12, 0, 0, 218, 2, this._box);
            var loc13=this.getSp();
            this._tfKillTip = ObjCreate.createTextField("", 5, 0, 100, 16, loc13, GlobalStyle.textFormat6);
            this._tfKillAdd = ObjCreate.createTextField("", 105, 0, 100, 16, loc13, GlobalStyle.textFormat6);
            var loc14=this.getSp();
            this._tfNextKill = ObjCreate.createTextField("", 5, 0, 100, 16, loc14, GlobalStyle.textFormat8);
            this._tfNextKillAdd = ObjCreate.createTextField("", 105, 0, 100, 16, loc14, GlobalStyle.textFormat8);
            return;
        }

        /* internal  */onTextTarget(arg1: Object /* flash.events.TextEvent */): void
        {
            CutCountDetails.instance.show();
            return;
        }

        
        {
            CoinCopyInfoView.Expand = Language.getString(42014);
            CoinCopyInfoView.Shrink = Language.getString(42015);
        }

        public updateCoin(arg1: int, arg2: int): void
        {
            if (arg1 - this._coin > 0 && arg1 - this._coin < 100) 
            {
                SoundManager.instance.soundPlay(SoundTypeConst.PickUpCoins);
            }
            this._coin = arg1;
            this._tfGetCoinNum.text = arg1.toString();
            this._tfGetBindCoinNum.text = arg2.toString();
            return;
        }

        /* internal  */onLoadComplete(arg1): void
        {
            this._bmpDetails.bitmapData = arg1.bitmapData as Object /* flash.display.BitmapData */;
            return;
        }

        /* internal  */onSecViewTimeChange(arg1: DataEvent): void
        {
            var loc2=null;
            var loc1=int(arg1.data);
            if (loc1 >= 10 * 60) 
            {
                this._tfLeftTime.setTextFormat(this._textFormatTime1);
            }
            else if (loc1 >= 5 * 60) 
            {
                this._tfLeftTime.setTextFormat(this._textFormatTime2);
            }
            else 
            {
                this._tfLeftTime.setTextFormat(this._textFormatTime3);
            }
            return;
        }

        /* internal  */onMoveBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (arg1.type == flash.events.MouseEvent.MOUSE_DOWN) 
            {
                this.startDrag();
            }
            if (arg1.type == flash.events.MouseEvent.MOUSE_UP) 
            {
                this.stopDrag();
            }
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            this._tfLeftTime.setLeftTime(arg1);
            return;
        }

        public updateKill(arg1: int, arg2: int, arg3: int): void
        {
            this._tfKillBossNum.text = arg1.toString();
            this._tfKillMonsterNum.text = arg2.toString();
            var loc1=this.getMaxKillHtmlTexts(arg3);
            this._tfKillTip.htmlText = loc1[0];
            this._tfKillAdd.htmlText = loc1[1];
            this._tfNextKill.htmlText = loc1[2];
            this._tfNextKillAdd.htmlText = loc1[3];
            return;
        }

        /* internal  */getMaxKillHtmlTexts(arg1: int): Array<any>
        {
            var loc5=0;
            var loc6=0;
            var loc1=new Array<any>();
            var loc2=CopyScoreConfig.instance.getCoinCopyAddNumByCutDown(arg1);
            var loc3=CopyScoreConfig.instance.getCoinCopyNextKeyValueByByCutDown(arg1);
            var loc4=Language.getStringByParam(42019, arg1.toString());
            loc1.push(loc4);
            if (loc2 != 0) 
            {
                loc4 = Language.getStringByParam(42021, loc2.toString());
                loc1.push(loc4);
            }
            else 
            {
                loc4 = Language.getString(42020);
                loc1.push(loc4);
            }
            if (loc3) 
            {
                loc5 = loc3["key"];
                loc6 = loc3["value"];
                loc1.push(Language.getStringByParam(42022, loc5.toString()));
                loc1.push(Language.getStringByParam(42023, loc6.toString()));
            }
            else 
            {
                loc1.push("");
                loc1.push("");
            }
            return loc1;
        }

        /* internal  */onZoomBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._zoomBtn.show) 
            {
                this.hidePanel();
            }
            else 
            {
                this.showPanel();
            }
            return;
        }

        /* internal  */onTaskTrackClick(arg1: DataEvent): void
        {
            if (arg1.data && this._zoomBtn.show) 
            {
                this.hidePanel();
            }
            return;
        }

        public hidePanel(): void
        {
            if (this._showTween && this._showTween.active) 
            {
                this._showTween.kill();
            }
            x = SceneRange.display.width - CoinCopyInfoView.__width + 26;
            y = CoinCopyInfoView.__y + 95;
            this._hideTween = TweenMax.to(this._bodySp, 0.2, {"x": CoinCopyInfoView.__width, "ease": Quint.easeOut, "onComplete": this.onHideEnd});
            this._zoomBtn.show = false;
            return;
        }

        /* internal  */onHideEnd(): void
        {
            if (this._bodySp.parent) 
            {
                removeChild(this._bodySp);
            }
            return;
        }

        public showPanel(): void
        {
            if (TaskCache.showTrack) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.TaskTrackShowOrHide, false));
            }
            if (this._hideTween && this._hideTween.active) 
            {
                this._hideTween.kill();
            }
            x = SceneRange.display.width - CoinCopyInfoView.__width;
            y = CoinCopyInfoView.__y;
            this._showTween = TweenMax.to(this._bodySp, 0.2, {"x": 0, "ease": Quint.easeIn});
            this._zoomBtn.show = true;
            if (!this._bodySp.parent) 
            {
                addChild(this._bodySp);
            }
            return;
        }

        /* internal  */getSp(): Object /* flash.display.Sprite */
        {
            var loc1=new Object /* flash.display.Sprite */();
            loc1.mouseEnabled = false;
            this._box.addChild(loc1);
            return loc1;
        }

        public resetPosition(): void
        {
            this.x = Global.stage.stageWidth - CoinCopyInfoView.__width;
            this.y = CoinCopyInfoView.__y;
            return;
        }

        /* internal */ static /* const */__width: number=260;

        /* internal */ static /* const */__y: number=193;

        /* internal */ /* var */_bodySp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_topSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_btn2: GButton;

        /* internal */ /* var */_moveBtn: GButton;

        /* internal */ /* var */_btnDetails: GButton;

        /* internal */ /* var */_zoomBtn: TowerInfoHideButton;

        /* internal */ /* var */_spContent: Object /* flash.display.Sprite */;

        /* internal */ /* var */_box: GBox;

        /* internal */ /* var */_tfLeftTime: SecTimerView;

        /* internal */ /* var */_tfGetCoinNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfGetBindCoinNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfKillBossNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfKillMonsterNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfKillTip: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfKillAdd: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfNextKill: Object /* flash.text.TextField */;

        /* internal */ /* var */_textFormatTime1: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_textFormatTime2: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_textFormatTime3: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_coin: int;

        /* internal */ /* var */_hideTween: TweenMax;

        /* internal */ /* var */_bmpDetails: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfNextKillAdd: Object /* flash.text.TextField */;

        public static /* var */Expand: string;

        public static /* var */Shrink: string;

        /* internal */ /* var */_showTween: TweenMax;
    }
